<%--
 * list.jsp
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 --%>

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl"	uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags" %>

<display:table pagesize="5" class="displaytag" 
name="auctions" requestURI="${URI}" id="row">
	
	<!-- Attributes -->
	
	<spring:message code="auction.painting" var="paintingHeader" />
	<display:column property="painting.title" title="${paintingHeader}" sortable="true" />
	
	<spring:message code="auction.startMoment" var="startMomentHeader" />
	<display:column property="startMoment" title="${startMomentHeader}" sortable="true" />
	
	<spring:message code="auction.finishMoment" var="finishMomentHeader" />
	<display:column property="finishMoment" title="${finishMomentHeader}" sortable="true"/>
	
	<spring:message code="auction.startingPrice" var="startingPriceHeader" />
	<display:column property="startingPrice" title="${startingPriceHeader}" sortable="true"/>
	
	<spring:message code="auction.winningBid" var="winningBidHeader" />
	<display:column property="winningBid.money" title="${winningBidHeader}" sortable="true"/>
	
	<security:authorize access="hasAnyRole('ADMIN','CUSTOMER')">
		<jstl:if test="${URI == \"/auction/customer/listActiveCreatedByOthers.do\"
		|| URI == \"/auction/admin/list.do\"}">
		
			<display:column>
				<spring:message code="auction.bids" var="bidsMessage" />
				<input type="button" name="bids"
					value="${bidsMessage}"
					onclick="javascript: window.location.replace('bid/actor/list.do?auctionId=${row.id}')" />
			</display:column>
			
		</jstl:if>
	</security:authorize>
	
	<security:authorize access="hasRole('CUSTOMER')">
		<jstl:if test="${URI == \"/auction/customer/listPastByPrincipal.do\" && row.winningBid == null}">
		
			<display:column>
				<spring:message code="auction.ChooseWinningBid" var="bidsMessage" />
				<input type="button" name="bids"
					value="${bidsMessage}"
					onclick="javascript: window.location.replace('bid/actor/list.do?auctionId=${row.id}&aux=1')" />
			</display:column>
			
		</jstl:if>
	</security:authorize>
	<security:authorize access="hasRole('CUSTOMER')">
		<jstl:if test="${URI == \"/auction/listActive.do\" && row.creator == principal }">
		
			<display:column>
				<spring:message code="auction.makeBid" var="makeBid" />
				<input type="button" name="bids"
					value="${bidsMessage}"
					onclick="javascript: window.location.replace('bid/customer/create.do?auctionId=${row.id}')" />
			</display:column>
			
		</jstl:if>
	</security:authorize>
	
</display:table>